<template>
  <div class="OrderAwaitingReviewList">
    <van-list :finished="true" finished-text="没有更多了">
      <order-awaiting-review-list-item v-for="order in orders" :key="order.id" :order="order"/>
    </van-list>
  </div>
</template>

<script>
import { order, security } from "@mall/api-services"
import OrderAwaitingReviewListItem from "@/views/order/OrderAwaitingReviewListItem"
import { List } from "vant"

export default {
  name: "OrderAwaitingReviewList",
  components: {
    OrderAwaitingReviewListItem,
    [List.name]: List,
  },
  data() {
    return {
      orders: [],
    }
  },
  created() {
    this.refreshOrders()
  },
  methods: {
    refreshOrders() {
      order.OrderServiceV1
          .createOrderQuery()
          .customerId(security.SubjectHolder.getUser().id)
          .statuses(order.OrderStatus.Completed)
          .reviewStatuses([order.OrderStatus.Incomplete, order.OrderStatus.AwaitingReview].join(","))
          .list()
          .then(pageOrders => this.orders = pageOrders.elements)
    },
  },
}
</script>

<style lang="scss" scoped>
.OrderAwaitingReviewList {

}
</style>
